package com.FengChaoSystem.servlet;

import com.FengChaoSystem.pojo.Occupy;
import com.FengChaoSystem.pojo.Order;
import com.FengChaoSystem.service.OccupyImpl;
import com.FengChaoSystem.service.OccupyService.OccupyService;
import com.FengChaoSystem.service.OrderImpl;
import com.FengChaoSystem.service.OrderService.OrderService;
import com.alibaba.fastjson.JSON;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/Occupy/*")
public class OccupyServlet extends BaseServlet{
    OccupyImpl service=new OccupyService();

    /**
     * 查看取件消息的时候用
     * @param request
     * @param response
     * @throws Exception
     */
    public void selectGetWordAndReceiveAddress(HttpServletRequest request, HttpServletResponse response) throws Exception {
        String onlyId = request.getParameter("onlyId");
        Occupy occupy=new Occupy();
        occupy.setOnlyId(onlyId);
        OrderImpl temp=new OrderService();
        Order order=new Order();
        order.setOnlyId(onlyId);
        Order resultOrder = temp.select(order);
        if(resultOrder.getStatus()==2||resultOrder.getStatus()==3){
        Occupy result = service.selectGetWordAndReceiveAddress(occupy);
        String jsonString = JSON.toJSONString(result);
        response.setContentType("text/json;charset=utf-8");
        response.getWriter().write(jsonString);}else{
            response.getWriter().write("null");
        }
    }


}
